import { Button } from '@nutui/nutui-react-taro';
import { View, Text } from '@tarojs/components';
import { IUser } from '@/types/user';
import Taro from '@tarojs/taro';
import './row-display.less';

interface IProps {
  user: IUser;
}

export default function Index(props: IProps) {
  const { user } = props;
  const goRechargePage = () => {
    if (!user) {
      Taro.navigateTo({ url: '/pages/login/index' });
      return;
    }
    Taro.navigateTo({ url: '/pages/contact-manage/index' });
  };

  const goWithdrawalPage = () => {
    if (!user) {
      Taro.navigateTo({ url: '/pages/login/index' });
      return;
    }
    // Taro.navigateTo({ url: '/pages/withdrawal/index' });
    Taro.navigateTo({ url: '/pages/contact-manage/index' });
  };

  return (
    <View className="mine-row-display">
      <View className="display-item display-item-left">
        <View className="title">我的额度</View>
        <View className="button-box">
          <View>
            <Text className="text-number">
              {user ? user.token : '--'}&nbsp;cc
            </Text>
          </View>
          <Button size="small" onClick={goRechargePage}>
            去投喂
          </Button>
        </View>
      </View>
      <View className="display-item display-item-right">
        <View className="title">我的钱包</View>
        <View className="button-box">
          <View>
            <Text className="text-number">
              {user ? user.balance : '--'}&nbsp;
            </Text>
          </View>
          <Button size="small" onClick={goWithdrawalPage}>
            未开放
          </Button>
        </View>
      </View>
    </View>
  );
}
